﻿Namespace Logic.Contracts
    Public Module MdulLogic
        Structure PaymentSchedual
            Dim intPaymentOrder As Integer
            Dim dblPaymentAmount As Double
            Dim dblPrincipalPayment As Double
            Dim dblInterestPayment As Double
            Dim intPaymentDays As Integer
            Dim strCurrency As String
            Dim dtePaymentDate As Date
            Dim strTenor As String
        End Structure

        Function GetTenor(ByVal intDays As Integer) As String
            Dim GetTinor As String
            Select Case intDays
                Case 0 : GetTinor = "ON"
                Case 1 To 7 : GetTinor = "1W"
                Case 8 To 14 : GetTinor = "2W"
                Case 15 To 21 : GetTinor = "3W"
                Case 22 To 30 : GetTinor = "1M"
                Case 31 To 60 : GetTinor = "2M"
                Case 61 To 90 : GetTinor = "3M"
                Case 91 To 120 : GetTinor = "4M"
                Case 121 To 150 : GetTinor = "5M"
                Case 151 To 180 : GetTinor = "6M"
                Case 181 To 210 : GetTinor = "7M"
                Case 211 To 240 : GetTinor = "8M"
                Case 241 To 270 : GetTinor = "9M"
                Case 271 To 300 : GetTinor = "10M"
                Case 301 To 330 : GetTinor = "11M"
                Case 331 To 365 : GetTinor = "1Y"
                Case 366 To 540 : GetTinor = "18M"
                Case 541 To 730 : GetTinor = "2Y"
                Case 731 To 1095 : GetTinor = "3Y"
                Case 1096 To 1460 : GetTinor = "4Y"
                Case 1461 To 1825 : GetTinor = "5Y"
                Case 1826 To 2190 : GetTinor = "6Y"
                Case 2191 To 2555 : GetTinor = "7Y"
                Case 2556 To 2920 : GetTinor = "8Y"
                Case 2921 To 3285 : GetTinor = "9Y"
                Case 3266 To 3650 : GetTinor = "10Y"
                Case 3651 To 7300 : GetTinor = "20Y"
                Case 7301 To 10950 : GetTinor = "30Y"
                Case Else : GetTinor = "30Y+"

            End Select
            Return GetTinor
        End Function

    End Module
End Namespace

